@echo off
rem build & deploy main Controll
:choice
echo ################################################
echo ## build deploy main controll
echo ## choose:
echo ##      modify version release        = choose vr
echo ##      modify version snapshot       = choose vs
echo ##      build                         = choose b
echo ##      install                       = choose i
echo ##      deploy                        = choose d
echo ##      package                       = chosse p
echo ##      clear                         = choose c
echo ##      q=exit:
echo ##
echo ################################################
rem check the choice info
set /P action=please choose your action:
if /I "%action%"=="vr" goto version-release
if /I "%action%"=="vs" goto version-snapshot
if /I "%action%"=="b" goto build
if /I "%action%"=="i" goto install
if /I "%action%"=="d" goto deploy
if /I "%action%"=="p" goto package
if /I "%action%"=="c" goto clear
if /I "%action%"=="q" goto quit
if /I "%action%"=="" goto quit

:version-release
rem modify pom version
set /P VERSION=please input release version eg 1.2.1:
if /I "%VERSION%" == "" goto choice
start mvn -U -f pom.xml versions:set -DnewVersion=%VERSION%.RELEASE
echo "start mvn -f pom.xml  versions:set -DnewVersion=%VERSION%.RELEASE"
echo "press any key to continue" & pause>nul
goto choice

:version-snapshot
rem modify pom version
set /P VERSION=please input release version eg 1.2.1:
if /I "%VERSION%" == "" goto choice
start mvn -U -f pom.xml  versions:set -DnewVersion=%VERSION%-SNAPSHOT
echo "start mvn  -f pom.xml  versions:set -DnewVersion=%VERSION%-SNAPSHOT"
echo "press any key to continue" & pause>nul
goto choice

:build
start mvn -U -f pom.xml clean compile -Dmaven.test.skip=true
echo "start mvn -f pom.xml clean compile -Dmaven.test.skip=true"
echo "press any key to continue" & pause>nul
goto choice

:package
start mvn -U -f pom.xml clean package spring-boot:build-info -Dmaven.test.skip=true
echo "start mvn -f pom.xml clean package spring-boot:build-info -Dmaven.test.skip=true"
echo "press any key to continue" & pause>nul
goto choice

:install
start mvn -U -f pom.xml clean install -Dmaven.test.skip=true
echo "start mvn -f pom.xml clean install -Dmaven.test.skip=true"
echo "press any key to continue" & pause>nul
goto choice

:deploy
start mvn -U -f pom.xml clean deploy -Dmaven.test.skip=true
echo "start mvn -f pom.xml -U clean deploy -Dmaven.test.skip=true"
echo "press any key to continue" & pause>nul
goto choice

:clear
rem clear pom.xml.versionBackup, dependency-reduced-pom.xml
set BASE_DIR=%~dp0%
set FILE1=pom.xml.versionsBackup
set FILE2=dependency-reduced-pom.xml
for /r %BASE_DIR% %%a in (%FILE1%, %FILE2%) do (
  if exist %%a (
    echo %%a
    del /f/q %%a
  )
)
start mvn -U -f pom.xml clean

echo "press any key to continue" & pause>nul
goto choice

:quit
echo existing ..
pause
exit



